<?php


  function service_registration_form_validation($form) {
//print_r($form); die;
    $stat = new set_static_variable();

//check the corresponding concerned dept name
//chk_concerned_dept($form['field_src_dept']);
    //Duplication in title
    //check_title_duplication($form['title'], $form['type']['#value'], $form['field_src_dept'], 'field_src_dept', $stat->get_nid());
    $stat->set_nid(0);

	// District
	distvalidation($form['field_src_dist']['und']['#value']);
	/*if(sizeof($form['field_src_dist']['value']['#value'])>1 && $form['field_src_dist']['value']['#value'][0]==0){
    
        $field=$form['field_src_dist']['value']['#value'][0];
        $field_title=$form['field_src_dist']['#title'];
         
     
    form_set_error($field, $field_title . ' field can have either \'ALL\' or \'Other Districts\'');
    
    }*/
	
    // maximum length validation for Title and Description Field
    maxlength_validation($form['title']['#value'], 255, $form['title']['#title'], 'title');
	
	// minimum length charcter   
  	minilength_validation($form['title']['#value'], 5, $form['title']['#title'], 'title');
  	minilength_validation($form['field_src_keyword']['und'][0]['value']['#value'], 5, $form['field_src_keyword']['und'][0]['value']['#title'],'field_src_keyword');
	minilength_validation($form['field_scr_desc']['und'][0]['value']['#value'], 5, $form['field_scr_desc']['und'][0]['value']['#title'],'field_scr_desc');

    // Check bad character validation for Title and Description field 
    chkbadchar($form['title']['#value'], $form['title']['#title'], 'title');  
    chkbadchar($form['field_scr_desc']['und'][0]['value']['#value'], $form['field_scr_desc']['und'][0]['value']['#title'], 'field_scr_desc');
	chkbadchar($form['field_src_keyword']['und'][0]['value']['#value'], $form['field_src_keyword']['und'][0]['value']['#title'], 'field_src_keyword');
	chkbadchar($form['field_web_othercategory']['und'][0]['value']['#value'], $form['field_web_othercategory']['und'][0]['value']['#title'], 'field_web_othercategory');
	// Date Validation  

   //check_scheduler_date_expire($form['scheduler_settings']['unpublish_on']['date']['#value'],'unpublish_on');

  // Form Type validtion
	url_validation($form['field_src_website']['und'][0]['value']['#value']);
  
  //$form_type = $form['field_src_type'];
 
  //if ($form_type['value']['#value'] == 'OnlineAvailable') {
  	
	
  	//$reference_url = $form['field_src_website']['und'][0]['value']['#value'];
   
	
    //if(isURL($reference_url) == 0 && $reference_url != '') {
      //form_set_error('field_src_website', t('Not a valid URL given in %name field', array('%name' => $form['field_src_website']['und'][0]['value']['#value']['#title'])));    
    //}
    //elseif ($reference_url == '') {
      //form_set_error('field_src_website', t(' %name field is required', array('%name' => $form['field_src_website']['und'][0]['value']['#value']['#title'])));
    //}
  //}
	if ($form['field_src_type']['und']['#value'] == 'download') { 
    // Validating the file size   
    //$field_obj = $form['field_act_file_upload']; 
	//$file_allowed_obj = $form_type;
	//print_r($form['field_act_file_upload']);
	$filename = $form['field_src_upload']['und'][0]['#file']; 
	$filename->filename;
    file_upload_validation_D7($filename->filename,$form['field_src_type']['und']['#title']);  
  
  }
 
  
  } //function service_registration_form_validation()



  function service_presave_validation($node) {  //print '<pre>'; print_r($node); print '</pre>';exit;
    $reference_url = $node->field_src_website['und'][0]['value'];
    $node->field_src_website['und'][0]['value'] = url_validation($reference_url);
  } // function service_presave_validation()



